const express = require("express");
const { Buffer } = require("buffer");
const route = express.Router();

const { graphql, buildSchema } = require("graphql");
var schema = buildSchema(`
  type Query {
    hello: String
  }
`);

var root = { hello: () => "Hello world!" };

graphql(schema, "{ hello }", root).then((response) => {
  console.log(response);
});

// 查询任务列表
route.get("/list/:status/:page", async (req, res, next) => {
  res.header("Content-Type", "application/json; charset=utf-8");
  res.json({
    list: [1, 2, 3],
  });
});

// 创建任务
route.post("/create", async (req, res, next) => {
  let { name, deadline, content } = req.body;
  res.json({
    todo: {},
  });
});

module.exports = route;
